<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>008-创建对象</title>
</head>
<body>
    
</body>
<script>
    console.log('008-01');
    function Person(name , age){
        this.name = name ;
        this.age = age;
        this.sayHi = function(){
            console.log(`hello : ${this.name} , you are : ${this.age}`);
        }
        // var that = this;
        this.sayLately = function(){
            setTimeout(function(){
                this.sayHi();
            },3000);
        }
    }

    let p01 = new Person('hhh' , 18);
    p01.sayHi();
    // p01.sayLately();

    // let o01 = new Object();
    // Person.call(o01 , 'oo001' , 11);
    // console.log('o01 constructor : ');
    // console.log(o01.constructor == o01.__proto__.constructor);


    // function MockObj(words){
    //     var obj = new Object();
    //     obj.words = words;
    //     window.obj = obj;
    //     return obj;
    // }
    // let m01 = new MockObj('new a obj');
    // console.log(m01);
    // console.log(window.obj);
    // console.log(window.obj === m01 );
    // let m02 = MockObj('new a obj');
    // console.log(m02);

</script>
</html>